import { reqcatelist } from "../../http/api"
let state = {
    //初始化数据
    list: []
}
let getters = {
    //导出数据
    list(state) {
        return state.list
    }
}
let mutations = {
    //修改list
    changeList(state, list) {
        state.list = list
    }
}
let actions = {
    //list的逻辑
    reqList(context) {
        //发请求
        reqcatelist({ istree: true }).then(res => {
            if (res.data.code == 200) {
                //得到数据给list赋值
                context.commit("changeList", res.data.list ? res.data.list : [])
            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    //命名空间
    namespaced: true
}